// 引入样式
require("../../assets/fonts/iconfont.css");

require("../../assets/css/normalize.css");
require("../../assets/css/reset.css");
require("../../assets/fontst/iconfont.css");
require("../../assets/css/sports.less");
require("../../assets/css/tabbar.less");

require("./mine.less");

// 引入模块
let dom = require("../../utils/dom.js");
// 引入插件
let axios = require("axios");
document.addEventListener("DOMContentLoaded", function () {
	//渲染tabbar
	dom.tabbar("mine");
	// 发送请求获取客户信息
	axios.defaults.baseURL = "http://fitness.h5.itsource.cn:3701";
	let token = localStorage.getItem("token");
	axios.defaults.headers.common["Authorization"] = "Bearer " + token;
	console.log("1111111111111111111", token);
	axios.get("/api/user/info").then((res) => {
		console.log("22222222222222222", res);
		// 渲染头像
		dom.get(
			"#photo"
		).style.background = `url(http://fitness.h5.itsource.cn:3701${res.data.data.imgUrl})`;
		// 渲染用户名
		dom.get("#nickName").textContent = res.data.data.nickName;
		// 渲染个性签名
		dom.get("#sign").textContent = res.data.data.sign;
		// 渲染总运动
		dom.get("#duration").textContent = res.data.data.duration;
		// 渲染本周消耗
		dom.get("#calorie").textContent = res.data.data.calorie;
		// 渲染vip member.id
		// if (res.data.data.id !== res.data.data.member.id) {
		// 	dom.get("#isVip").style.display = "none";
		// }
	});
	dom.get(".mine-btn").addEventListener("click", function(){
//清除token
localStorage.clear();
location.href = "login.html";
	})
	
});
